package com.eternal.base;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Switch;

public class StatueSwitch extends Switch {
    private boolean isTouched;
    public StatueSwitch(Context context) {
        super(context);
    }

    public StatueSwitch(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public StatueSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if(ev.getAction()==MotionEvent.ACTION_DOWN){
            isTouched=true;
        }else if(ev.getAction()==MotionEvent.ACTION_UP){
            isTouched=false;
        }
        return super.onTouchEvent(ev);
    }

    public boolean isTouched(){
        return isTouched;
    }
}
